class BeginLogic {
	public constructor() {
	}
	private static instance: BeginLogic;
	public static getInstance(): BeginLogic {
		if (this.instance == null) {
			this.instance = new BeginLogic();
		}
		return this.instance;
	}

	private ui: BeginUI;
	private bmp_bg: egret.Bitmap;
	private cast_bg: egret.Bitmap;

	public openUI(con: any, _ui: BeginUI, arg: any = null): void {
		if (this.ui == null) {
			this.ui = _ui;
			con.addChild(this.ui);
			this.ui.logic = this;
			if (this.ui.inited) {
				this.init();
			}
		}
	}

	public init() {
		console.log("BeginLogic.init", this.ui.inited, this.ui.logic);
		this.checkFit();
		this.initData();
		this.initView();
		this.initEvent();
	}

	private checkFit() {
		// this.ui.gp_bg.height = this.ui.rect_bg.height = this.ui.img_bg.height = GameData.stageHeight;
		if(GameData.stageWidth > 1335 || GameData.stageHeight>750){
			
		}
	}

	private initData() {
	}

	private initView() {

	}
	


	private initEvent() {
		this.ui.img_bg.addEventListener(egret.TouchEvent.TOUCH_TAP, this.closeCast, this);
		// WxApi.getInstance().addEventListener(GameEvent.REWARDAD_CLOSE_EVENT, this.watchReward, this);
		GameData.GameStage.addEventListener(egret.Event.ENTER_FRAME, this.enterframe, this);
		this.ui.img_start.addEventListener(egret.TouchEvent.TOUCH_TAP, this.start_game, this);
	}

	private start_game(){
		GameLogic.getInstance().openUI(GameData.main, new GameUI(), []);
		if (this.ui != null && this.ui.parent != null) {
			this.ui.parent.removeChild(this.ui);
			this.clear();
		}
		console.log('game start');
	}

	private closeCast(){
		
	}


	private initSkin() {

	}


	private watchReward(){

	}


	private enterframe() {
	
	}

	private clearEvent() {
		// WxApi.getInstance().removeEventListener(GameEvent.REWARDAD_CLOSE_EVENT, this.watchReward, this);
		GameData.GameStage.removeEventListener(egret.Event.ENTER_FRAME, this.enterframe, this);
	}

	private clickShare() {
		// WxApi.getInstance().share(SHARETYPE.SHARE);
	}

	public pause() {

	}

	public resume() {
		console.log("beginloic:resume");
	}



	public clear() {
		this.clearEvent();
	}
}